package com.bitdf.txing.search.exeception;

import com.bitdf.txing.common.enume.TxCodeEnume;
import com.bitdf.txing.common.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.ElasticsearchStatusException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author Lizhiwei
 * @date 2023/1/27 1:02:04
 * 注释：
 */
@Slf4j
@RestControllerAdvice(basePackages = "com.bitdf.txing.search.controller")
public class ESExceptionControllerAdvice {
    /**
     * Elasticsearch exception [type=document_missing_exception, reason=[_doc][12]: document missing]
     * @param e
     * @return
     */
    @ExceptionHandler(ElasticsearchStatusException.class)
    public R handleElasticsearchStatusException(ElasticsearchStatusException e){
        return R.error(TxCodeEnume.TARGET_DOCS_NOT_EXIST_EXCEPTION);
    }



}
